package com.eliza.base.views.device.bluetooth.network

import com.eliza.library.utils.net.OptionResult
import com.eliza.library.utils.net.HttpClient
import com.eliza.base.views.device.bluetooth.data.DeviceResponse
import javax.inject.Inject
import javax.inject.Singleton


@Singleton
class RetrofitCosmo @Inject constructor(
    cosmoService: HttpClient
) : CosmoDataSource {

    private val networkApi = cosmoService

    //    override suspend fun getDevicesSource(): DeviceResponse = networkApi.getDevices()
    override suspend fun getDevicesSource(): DeviceResponse {
        val getx = networkApi.getx<DeviceResponse>("/") {}
        return when (getx) {
            is OptionResult.Error -> DeviceResponse(emptyList())
            is OptionResult.Success -> getx.data
        }
    }
}